package sk.avicularia.core.data;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import sk.avicularia.core.dao.DocumentDAO;
import sk.avicularia.core.dao.PersonDAO;

/**
* Entita mapujuca strukturu dokument
* 
* @author leaflock
* @since  0.1
*/
@Entity
@Table(name = DocumentDAO.TABLE_NAME)
public class Document implements Serializable
{

	/**
	 * @see Serializable
	 */
	private static final long	serialVersionUID	= -8918652607596999072L;
	
	/**
	 * Id zaznamu
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", nullable = false)
	private Long id;
	
	/**
	 * Author clanku
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = DocumentDAO.COLUMN_ID_AUTHOR, referencedColumnName = "ID", table = PersonDAO.TABLE_NAME)
	private Person author;

	/**
	 * Sefredaktor co clanok schvalil
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = DocumentDAO.COLUMN_ID_CHIEF_EDITOR, referencedColumnName = "ID", table = PersonDAO.TABLE_NAME)
	private Person chiefEditor;
	
	/**
	 * Titul dokumentu
	 */
	@Column(name = DocumentDAO.COLUMN_TITLE, nullable = false, length = 50)
	private String title;
	
	/**
	 * Abstract dokumentu
	 */
	@Column(name = DocumentDAO.COLUMN_ABSTRACT, nullable = false, length = 255)
	private String abstrakt = "";
	
	@Embedded
	GeneralObjects generalObjects;
	
	/**
	 * Datum expiracie dokumentu
	 */
	@Column(name = DocumentDAO.COLUMN_EXPIRATED)
	private Date expirated;
	
	/**
	 * Kto zaznam naposledy modifikoval
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = DocumentDAO.COLUMN_MODIFIED_BY, referencedColumnName = "ID", table = PersonDAO.TABLE_NAME)
	private Person modified_by;
	
	/**
	 * Link na dany dokument
	 */
	@Column(name = DocumentDAO.COLUMN_LINK, nullable = false, length = 255)
	private String link = "";

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public Person getAuthor()
	{
		return author;
	}

	public void setAuthor(Person author)
	{
		this.author = author;
	}

	public Person getChiefEditor()
	{
		return chiefEditor;
	}

	public void setChiefEditor(Person chiefEditor)
	{
		this.chiefEditor = chiefEditor;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public String getAbstrakt()
	{
		return abstrakt;
	}

	public void setAbstrakt(String abstrakt)
	{
		this.abstrakt = abstrakt;
	}

	public GeneralObjects getGeneralObjects()
	{
		return generalObjects;
	}

	public void setGeneralObjects(GeneralObjects generalObjects)
	{
		this.generalObjects = generalObjects;
	}

	public Date getExpirated()
	{
		return expirated;
	}

	public void setExpirated(Date expirated)
	{
		this.expirated = expirated;
	}

	public Person getModified_by()
	{
		return modified_by;
	}

	public void setModified_by(Person modified_by)
	{
		this.modified_by = modified_by;
	}

	public String getLink()
	{
		return link;
	}

	public void setLink(String link)
	{
		this.link = link;
	}
}
